#ifndef CONNECTION_H
#define CONNECTION_H

#include <QObject>
#include <QLocalSocket>
#include <QSocketNotifier>

class Connection : public QObject
{
    Q_OBJECT
public:
    explicit Connection(quint32 uid, int fd[2], QObject *parent = nullptr);

signals:
    void messageReceived(const QByteArray &buffer);
    void disconnected();

public slots:
    void writeMessage(const QByteArray &buffer);

private slots:
    void onSocketReadyRead();

private:
    QSocketNotifier *m_localSocketNotifier;
    QLocalSocket *m_localSocket;
};

#endif // CONNECTION_H
